<template>
  <el-dialog
    title="人员列表"
    :close-on-click-modal="false"
    :visible.sync="visible">
    <el-table
      :data="dataList"
      border
      v-loading="dataListLoading"
      style="width: 100%;">
      <el-table-column
        label="序号"
        type="index"
        header-align="center"
        align="center"
        width="50">
      </el-table-column>
      <el-table-column
        prop="username"
        header-align="center"
        align="center"
        label="姓名">
      </el-table-column>
      <el-table-column
        prop="mobile"
        header-align="center"
        align="center"
        label="手机号">
      </el-table-column>
    </el-table>
  </el-dialog>
</template>

<script>
  export default {
    data () {
      return {
        visible: false,
        dataListLoading: false,
        dataList:[]
      }
    },
    methods: {
      init (id) {
        this.dataListLoading = true
        this.$http({
          url: this.$http.adornUrl(`/sys/role/selectRoleUser`),
          method: 'post',
          data: this.$http.adornData({
            'roleId': id
          })
        }).then(({data}) => {
          if (data && data.code === 0) {
            this.dataList = data.result
            this.visible = true
          } else {
            this.$message.error(data.msg)
          }
          this.dataListLoading = false
        })
      }
    }
  }
</script>
